﻿<html>
<form method="POST" action="customerQuery.php">
	送貨單號：　　　<input type="text" name="_id"></br>
	寄件人手機號碼：<input type="text" name="_senderPhone"></br>
	收件人手機號碼：<input type="text" name="_receiverPhone"></br>
	<input type="submit" value="查詢貨物">
</form>

<?php
$_id = $_POST['_id'];
$_senderPhone = $_POST['_senderPhone'];
$_receiverPhone = $_POST['_receiverPhone'];

if($_id != 0)
{

	$found = False;

	$link = mysql_connect("localhost" , "root" , "1123");
	mysql_select_db("dd") or die("No database");

	$query = "	select weight, length, width, height, type, mailing_date, specified_delivery_date, actual_delivery_date, name
				from ship_start_view natural join warehouse
				where
					tracking_number = '" . $_id . "' and
					sender_phone = '" . $_senderPhone . "' and
					addressee_phone = '" . $_receiverPhone . "';";
					
	$result = mysql_query($query) or die("Error Message:".mysql_error());
		 
	if(list($a, $b, $c, $d, $e, $f, $g, $h, $i)= mysql_fetch_row($result))
	{
		$found = TRUE;
		$main ='<hr><table width="700" border="solid">';
		$main .=
		'
		<tr>
			<td align="center">重量</td><td align="center">' . $a . '</td>
		</tr>
		<tr>
			<td align="center">長</td><td align="center">' . $b . '</td>
		</tr>
		<tr>
			<td align="center">寬</td><td align="center">' . $c . '</td>
		</tr>
		<tr>
			<td align="center">高</td><td align="center">' . $d . '</td>
		</tr>
		<tr>
			<td align="center">類型</td><td align="center">' . $e . '</td>
		</tr>
		<tr>
			<td align="center">寄件日期</td><td align="center">' . $f . '</td>
		</tr>
		<tr>
			<td align="center">配送狀態</td><td align="center">' . "暫存" . $i . "倉庫" . '</td>
		</tr>
		<tr>
			<td align="center">預定送達日期</td><td align="center">' . $g . '</td>
		</tr>
		<tr>
			<td align="center">實際送達日期</td><td align="center">' . $h . '</td>
		</tr>
		';
		$main .='</table>';
		echo $main;
	}
	else
	{
		$query = "	select weight, length, width, height, type, mailing_date, specified_delivery_date, actual_delivery_date, name
				from ship_start_view natural join warehouse
				where
					tracking_number = '" . $_id . "' and
					sender_phone = '" . $_senderPhone . "' and
					addressee_phone = '" . $_receiverPhone . "';";
					
		$result = mysql_query($query) or die("Error Message:".mysql_error());
			 
		if(list($a, $b, $c, $d, $e, $f, $g, $h, $i)= mysql_fetch_row($result))
		{
			$found = TRUE;
			$main ='<hr><table width="700" border="solid">';
			$main .=
			'
			<tr>
				<td align="center">重量</td><td align="center">' . $a . '</td>
			</tr>
			<tr>
				<td align="center">長</td><td align="center">' . $b . '</td>
			</tr>
			<tr>
				<td align="center">寬</td><td align="center">' . $c . '</td>
			</tr>
			<tr>
				<td align="center">高</td><td align="center">' . $d . '</td>
			</tr>
			<tr>
				<td align="center">類型</td><td align="center">' . $e . '</td>
			</tr>
			<tr>
				<td align="center">寄件日期</td><td align="center">' . $f . '</td>
			</tr>
			<tr>
				<td align="center">配送狀態</td><td align="center">' . "暫存" . $i . "倉庫" . '</td>
			</tr>
			<tr>
				<td align="center">預定送達日期</td><td align="center">' . $g . '</td>
			</tr>
			<tr>
				<td align="center">實際送達日期</td><td align="center">' . $h . '</td>
			</tr>
			';
			$main .='</table>';
			echo $main;
		}
	}
}
				
?>

</html>